#include "tcpsocket.h"



TcpSocket::TcpSocket(QTcpSocket *socket, QObject *parent)
{
    this->socket = socket;

    create_room_id.clear();
    join_room_id.clear();

    // 创建的房间号，或者加入的房间号，总是只有一个是非空的。要么加入房间，要不创建房间，不能即加入房间，又创建房间


}

void TcpSocket::setName(const QString &name)
{
    this->name = name;
}

void TcpSocket::setCreateRoomId(const QString &create_room_id)
{
    this->create_room_id = create_room_id;
}

void TcpSocket::setJoinRoomId(const QString &join_room_id)
{
    this->join_room_id = join_room_id;
}

int TcpSocket::read(char *buf, int size)
{
    socket->read(buf, size);
}

int TcpSocket::write(const char *buf, int size)
{
    socket->write(buf, size);
}

QHostAddress TcpSocket::peerAddress()
{
    return socket->peerAddress();
}

int TcpSocket::peerPort()
{
    return socket->peerPort();
}

QTcpSocket *TcpSocket::getSock()
{
    return socket;
}

QString TcpSocket::getCreateRoomId()
{
    return create_room_id;
}

QString TcpSocket::getName()
{
    return name;
}


